<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script>
window.onload = function()
{
	var otxt1 = document.getElementById('txt1');
	var obtn = document.getElementById('btn1');
	
	obtn.onclick = function(){
		//一串英文 数字 下换线 @ 一串英文 数字 . 一串英文
		//var re = /\w+@[a-z0-9]+\.[a-z]+/i;
		var re = /^\w+@[a-z0-9]+\.[a-z]+$/i;   // ^行首   $行尾
		
		if(re.test(otxt1.value))
		{
			alert('correct');
		}
		else{
			alert('incorrect');
		}
		
	};
};
</script>
</head>

<body>
<input type="text" id="txt1">
<input type="button" id="btn1" value="验证"><br>
</body>
</html>
